#include "UTestControlWindow.h"
#include "Controls/UMemo.h"
#include "Controls/UEdit.h"
#include "Controls/UTextButton.h"
#include "Controls/UTexturedButton.h"
#include "Controls/UThemedButton.h"
#include "Controls/UComboBox.h"
#include "Controls/USlider.h"

TTestControlWindow::TTestControlWindow()
{
	memo	= new TMemo(TRectangle(0,90,200,150)),
	edit	= new TEdit(TRectangle(0, 35, 100, 60));
	buttona = new TTextButton("Button A", TGLFontRef(), TRectangle(0,0,100,30));
	buttonb = new TTexturedButton("elfenlied.png", TRectangle(110, 10, 150, 40));
	combobox= new TComboBox(TRectangle(50, 200, 150, 230));
	slider  = new TSlider(TRectangle(2,2,200, 12), Horizontal);
/*
	string strs[6] = {
	    //"Data/WindowThemes/Classic98/button_close.png",
	    "Data/WindowThemes/Classic98/button_close.png",
	    "Data/WindowThemes/Classic98/button_close.png",
	    "Data/WindowThemes/Classic98/button_close_pressed.png",
	    "Data/WindowThemes/Classic98/button_close.png",
	    "Data/WindowThemes/Classic98/button_close.png",
	    "Data/WindowThemes/Classic98/button_close_pressed.png",
	};
	int pos[4] = {100,100,116,114};
	buttonc = new TThemedButton(strs, pos);
*/
	combobox->AddItem("Item1");
	combobox->AddItem("Item2");
	combobox->AddItem("Item3");
	combobox->AddItem("Item1ffegg");

	buttona->onClick = boost::bind(&TTestControlWindow::onClick_ButtonA, this);
	edit->onEnter = boost::bind(&TTestControlWindow::editOnEnter, this);
	Controls.AddControl(buttona);
	Controls.AddControl(memo);
	Controls.AddControl(edit);
	Controls.AddControl(buttonb);
	Controls.AddControl(combobox);
	Controls.AddControl(slider);
	//Controls.push_back(buttonc);
}

void TTestControlWindow::onClick_ButtonA()
{
	buttona->visible = !buttona->visible;
	memo->Lines.push_back("Text!!!!");
}

void TTestControlWindow::editOnEnter()
{
	buttona->Text = edit->GetText();
	edit->SetText("");
}
